<!--运行环境修改阈值-->
<template>
  <div class="div_main">
    <!--  表单-->
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      :header-cell-style="{textAlign: 'center'}"
      :cell-style="{ textAlign: 'center' }"
    >

      <el-table-column
        prop="opId"
        label="设备id">
      </el-table-column>
      <el-table-column
        prop="opName"
        label="运行设备">
      </el-table-column>
      <el-table-column
        prop="opValue"
        label="阈值">
      </el-table-column>

      <el-table-column label="操作" width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary" class="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">
            修改
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 编辑窗口 -->
    <el-dialog
      title="编辑"
      :visible.sync="editFormVisible"
      width="25vw"
    >
      <el-form
        :model="editForm"
        ref="editForm"
      >
        <el-form-item
          label="阈值"
          label-width="80px"
        >
          <el-input
            v-model="editForm.opValue"
            autocomplete="off"
          ></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel()">取消</el-button>
        <el-button
          type="primary"
          v-on:click="sumbitEditRow()"
        >确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>

  var _index;
  export default {
    name: "yxhjConfig ",
    data() {
      return{
        tableData:[
        ],
        editFormVisible:false,
        //修改接收数组
        editForm:[
          {
            opId:'',
            opName:'',
            opValue: '',
          }
        ],

        rules: {},
        total: null,
        size: null,
      }
    },
    methods:{
      handleEdit(index, row) {
        this.editFormVisible = true;
        this.editForm = Object.assign({},row); //重置对象
        _index = index;
      },
      //保存数据
      sumbitEditRow() {
        var editData = _index;
        this.tableData[editData].opValue = this.editForm.opValue;
        this.$axios
          .put("opupd", this.editForm)
        this.editFormVisible = false;
      },
      cancel() {
        this.editFormVisible = false;
      },
    },
    created() {
      const _this = this;
      this.$axios
        .get("opqueryall/1/5")
        .then(function (resp) {
          //覆盖假数据
          _this.tableData = resp.data.content;
          _this.total = resp.data.totalElements;
          _this.size = resp.data.size;
        });
    },
  }
</script>

<style scoped>

</style>
